efform_onload = function ()
{
	if($('#flag').val()==1)
	{
	//	$('#ef_region_inqu').hidden();
		document.getElementById('ef_region_inqu').style.display = "none";		
		
	}
	$('#result_add-0-fdDepartment').val($('#fdDepartment').val());
	$('#result_add-0-fdDepartmentId').val($('#fdDepartmentId').val());

};   
/*根据主表查询明细*/
efgrid_onRowClicked = function( grid_id, row_index ){ 
	if(grid_id == "ef_grid_result"){ 
		var grid = efgrid.getGridObject(grid_id); 
		var selectedRow=grid.getRowData(row_index);
		for(var item in selectedRow){
			var colname=item;
			var colvalue=selectedRow[item];
			$('#ef_region_mainadd').find('#result_add-0-'+colname).val(colvalue);
		} 
		
	}
}


var ajax_callback = {
		onSuccess : function(eiInfo) {
			var grid = efgrid.getGridObject("ef_grid_result");
			grid.refresh(eiInfo);
		}, 
		onFail:function(eMsg)
		{
			alert("确认失败，原因："+eMsg);
		}

}	

button_insert_onclick = function (){
	var ei_info=new EiInfo();
	ei_info.setByNodeObject(document.forms[0]); 
	if(ei_info.getBlock('result_add').getRows(0)[0][31]==""){
		EFAlert("泵房名称不能为空");
		return;
	}
	
	
	var info = getDetail("ef_region_mainadd","result_add");
	if (null != info) {
		EiCommunicator.send("ZMCK34", "insert", info, ajax_callback);
	}
}

button_update_onclick = function (){
	var ei_info=new EiInfo();
	ei_info.setByNodeObject(document.forms[0]); 
	if(ei_info.getBlock('result_add').getRows(0)[0][31]==""){
		EFAlert("泵房名称不能为空");
		return;
	}
	
	var info = getDetail("ef_region_mainadd","result_add");	
	var status=$('#result_add-0-fdStatus').val();

	if (null != info && status != "上报" ) {
		
		EiCommunicator.send("ZMCK34", "update", info, ajax_callback);
	} else{
		EFAlert("只能对草拟的记录进行修改！"); return;
	} 
}


button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_result", "ZM","ZMCK34","query");
}

button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行删除！"); return;
		}
	}
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM","ZMCK34","delete",true);
	}); 
}


button_report_onclick = function (){
	if (isSelected("ef_grid_result") == 0)return; 
	EFConfirm('确认要上报吗?', '确认框', function(r) {
		efgrid.submitForm( "ef_grid_result", "ZM","ZMCK34","report",true);
	});
}

function change2Date2String()
{

	
}





